namespace Stee.CAP8.MessageBus.Sagas.Order.Sagas.Data
{
    using Stee.CAP8.MessageBus.Sagas.Core.Storages.SagaData;
    using Stee.CAP8.PropertyChangedNotificator;
    using Stee.CAP8.PropertyChangedNotificator.Attributes;

    public class OrderSagaData : BaseSagaData
    {
        /// <summary>
        /// 这个必须写
        /// </summary>
        public OrderSagaData() => Notificator.Create(this);
        public OrderSagaData(string sagaId) : this()//this()必须写
        {
            this.SagaId = sagaId;
        }
        /// <summary>
        /// 订单是否创建
        /// </summary>
        [NotifyProperty]
        public virtual bool OrderCreated { get; set; }
        /// <summary>
        /// <summary>
        /// 支付是否完成
        /// </summary>
        [NotifyProperty]
        public virtual bool OrderPaymented { get; set; }
        /// <summary>
        /// 库存是否调整
        /// </summary>
        [NotifyProperty]
        public virtual bool OrderStockAdjusted { get; set; }

        /// <summary>
        /// <summary>
        /// saga是否完毕,
        /// 这里可以自己去判断你的SAGA哪些状态ok就算执行完毕了
        /// </summary>
        /// <returns></returns>
        public override bool IsDone()
        {
            _ = this.SafeLoadData();
            return this.OrderCreated && this.OrderPaymented;
        }
    }




}
